<template>
  <div>
    <van-nav-bar title="消息">
    </van-nav-bar>
    <van-list>
      <van-cell v-for="(val, key,index) in device" :key="index">
        {{`${key}：${val}`}}
      </van-cell>
      <van-cell v-for="(item,index) in contact" :key="index">
        {{`name：${item.displayName}——phone:${item.phoneNumbers[0].value}`}}
      </van-cell>
    </van-list>
  </div>
</template>

<script>
import { getDevice, getContact } from '@/cordova/'
export default {
  name: 'message',
  data() {
    return {
      device: {},
      contact: {}
    }
  },
  created() {
    this.init()
  },
  computed: {},
  methods: {
    init() {
      this.$toast.loading({
        mask: true,
        message: '加载中。。。',
        duration: 0
      })
      getDevice()
        .then(data => {
          this.device = data
          return getContact()
        })
        .then(data => {
          this.contact = data
          this.$toast.clear()
        })
        .catch(err => {
          this.$toast(err)
        })
    }
  }
}
</script>

<style lang="scss">
</style>